package com.cwm.test.prototype;

import com.alibaba.fastjson.JSON;

public class Prototype implements Cloneable {

    public Prototype(String name){
        this.name=name;
        System.out.println("新建对象");
    }
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() {
        Object obj=null;
        try {
            obj =  super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        } finally {
            return obj;
        }
    }

    public static void main(String[] args) {
        Prototype pro = new Prototype("dddd");
        System.out.println(pro.getName());
        Prototype pro1 = (Prototype) pro.clone();
        System.out.println(JSON.toJSONString(pro1));
    }
}